﻿/*
    Copyright (c) Christian Ranz 2009
    http://www.christian-ranz.com
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogFileConnector
{
    class Program
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                Configuration.readConfig();
            }
            catch (Exception configError)
            {
                Console.WriteLine("Beim laden der Konfigutation ist ein Fehler aufgetreten. " + configError.Message);
            }
            if (args.Length == 2)
            {
                Configuration.destination = args[1];
                Configuration.source = args[0];
            }
            if (args.Length == 1 && args[0] == "help")
            {
                Console.WriteLine("============== HILFE ===============");
                Console.WriteLine("Syntax:   logFileConnector.exe [sourcepath] [destinationpath]");
                Console.WriteLine("Beispiel: logFileConnector.exe C:\\test C:\\test\\destination\\test.csv");
            }
            else
            {
                try
                {
                    FileFinder ff = new FileFinder();

                    LogConnector con = new LogConnector();
                    con.connectLogs(ff.findFiles(Configuration.source), Configuration.destination);
                }
                catch (Exception error)
                {
                    ErrorHandler.writeLog(error.Message);
                }
            }
        }
    }
}
